<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		p{
			display: inline-block;
		}
	</style>
</head>
<body>
	<button id="all">全选</button>
	<button id="fan">反选</button>
	<button id="notall">全不选</button>
	<p id="check">
		<input type="checkbox">
		<input type="checkbox">
		<input type="checkbox">
		<input type="checkbox">
		<input type="checkbox">
		<input type="checkbox">
		<input type="checkbox">
	</p>

	<script>
		//var ch=document.getElementsByTagName('input');
		var ch=check.children;
		all.onclick=function(){
			for(var i=0;i<ch.length;i++)
				ch[i].checked=true;
		}

		fan.onclick=function(){
			for(var i=0;i<ch.length;i++)
				ch[i].checked=!ch[i].checked;
		}

		notall.onclick=function(){
			for(var i=0;i<ch.length;i++)
				ch[i].checked=false;
		}

	</script>
</body>
</html>